package cn.com.bdqn.utils;


import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data

public class ReturnData {

    private String mess;//错误信息
    private int code; //错误编码
    private Map<String,Object> data=new HashMap<>();  //保存json对象的

    //成功
    public static ReturnData ok(){
        ReturnData returnData=new ReturnData();
        returnData.code=200;
        returnData.mess="成功";
        return returnData;
    }

    //失败
    public static ReturnData error(){
        ReturnData returnData=new ReturnData();
        returnData.code=500;
        returnData.mess="内部错误";
        return returnData;
    }

    //自定义错误
    public static ReturnData currError(String mess){
        ReturnData returnData = new ReturnData();
        returnData.code=500;
        returnData.mess=mess;
        return returnData;
    }

    //添加数据
    public ReturnData put(String key,Object value){
        this.data.put(key,value);
        return this;
    }
}
